﻿package org.dschini.utils
{
	dynamic public class ExtendedArray extends Array
	{
		public function ExtendedArray(... optionalArgs)
		{
			for each (var value:* in optionalArgs){
				super.push(value);
			}
		}
		
		private function __shuffle(a:*,b:*):int
		{
			var num : int = Math.round(Math.random()*2)-1;
			return num;
		}
		
		public function shuffle(startIndex:int = 0, endIndex:int = 0):Array
		{
			//var ss:Array = this.sort(__shuffle);
			return this.sort(__shuffle);
		}
		
		public function merge(...args):ExtendedArray 
		{
			var extendedArray:ExtendedArray = new ExtendedArray(); 
			for (var i:* in args) 
			{
				for (var j:* in args[i]) 
				{
					// type check done in push() 
					super.push(args[i][j]); 
				}
			}
			return this;
		}
	}
}
